import { h } from 'vue';
import { Tag } from 'ant-design-vue';

import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

// import { getDictTypeListApi } from '/@/api/admin/dict';
// import { DICT } from '/@/enums/dict';

export const columns: BasicColumn[] = [
  {
    title: '租户名称',
    dataIndex: 'name',
  },
  {
    title: '租户编码',
    dataIndex: 'code',
    width: 100,
  },

  {
    title: '租户域名',
    dataIndex: 'tenantDomain',
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    customRender: ({ record }) => {
      const status = record.typeStatus;
      const enable = ~~status === 0;
      const color = enable ? 'green' : 'red';
      const text = enable ? '正常' : '冻结';
      return h(Tag, { color }, () => text);
    },
  },
  {
    title: '开始时间',
    dataIndex: 'startTime',
  },
  {
    title: '结束时间',
    dataIndex: 'endTime',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '租户名称',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'tenantDomain',
    label: '租户域名',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '正常', value: '0' },
        { label: '冻结', value: '9' },
      ],
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'name',
    label: '租户名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'code',
    label: '租户编码',
    required: true,
    component: 'Input',
  },
  {
    field: 'tenantDomain',
    label: '租户域名',
    component: 'Input',
    required: true,
  },
  {
    field: 'startTime',
    label: '开始时间',
    required: false,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      style: 'width:100%',
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'endTime',
    label: '结束时间',
    required: false,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      style: 'width:100%',
      getPopupContainer: () => document.body,
    },
  },

  {
    field: 'status',
    label: '状态',
    component: 'Select',
    defaultValue: '0',
    componentProps: {
      allowClear: false,
      options: [
        { label: '正常', value: '0' },
        { label: '冻结', value: '9' },
      ],
    },
  },

  // {
  //   label: '租户描述',
  //   field: 'remark',
  //   component: 'InputTextArea',
  // },
];
